package jen.android.timecheckerwidget;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

public class CustomDialogActivity extends Activity {

	int widgetID;
	
	@Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    setContentView(R.layout.widgetdialog_activity);
	    
	    widgetID = getIntent().getExtras().getInt("id");

	    String dialogText = "This is the dialog text";
	    TextView txt = (TextView) findViewById(R.id.w_dialog_txt);
	    txt.setText(dialogText);

	    Button dismissbutton = (Button) findViewById(R.id.w_dismiss_btn);
	    dismissbutton.setOnClickListener(new OnClickListener() {
	      @Override
	      public void onClick(View v) {
	    	  Intent broadcastIntent = new Intent("jen.android.timecheckerwidget.STOP");
	    	  broadcastIntent.putExtra("id", widgetID);
	    	  //PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), 0, broadcastIntent, PendingIntent.FLAG_ONE_SHOT);
	    	  getBaseContext().sendBroadcast(broadcastIntent);
	    	  CustomDialogActivity.this.finish();
	      }
	    });
	    
	    Button changeButton = (Button) findViewById(R.id.w_change_btn);
	    changeButton.setOnClickListener(new OnClickListener(){
	    	@Override
	    	public void onClick(View v){
	    		Intent broadcastIntent = new Intent("jen.android.timecheckerwidget.TIMECHANGE");
	    		broadcastIntent.putExtra("id", widgetID);
	    		//PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), 0, broadcastIntent, PendingIntent.FLAG_ONE_SHOT);
	    		getBaseContext().sendBroadcast(broadcastIntent);
	    		CustomDialogActivity.this.finish();
	    	}
	    });
	  }
}
